<template>
    <div id="seachDialog">
      <a-modal
      title="快速筛选"
      width="550px"
      :visible="searchData.show"
      @cancel="handleClose">
        <el-row style="padding:30px 70px 50px 20px;overflow-y:auto;overflow-x:hidden;">
            <el-form :model="searchParames" ref="searchParames" label-width="120px">
                <el-form-item label="公司名称:"> <!-- 客户名称 -->
                    <el-input clearable size="small" v-model="searchParames.customerName" placeholder="请输入"></el-input>
                </el-form-item>
                <el-form-item label="联系人:">
                    <el-input clearable size="small" v-model="searchParames.contacts" placeholder="请输入"></el-input>
                </el-form-item>
                <el-form-item label="会计:">
                    <el-input clearable size="small" v-model="searchParames.accountantName" placeholder="请输入"></el-input>
                </el-form-item>
                <el-form-item label="合同状态:">
                    <el-select clearable style="width:100%" size="small" filterable v-model="searchParames.contractStatus" placeholder="请选择">
                        <el-option v-for="(item,index) in contractStatusData" :key="index" :label="item.desc" :value="item.name"></el-option>
                    </el-select>
                </el-form-item>
                <!-- <el-form-item label="合同类型:">
                    <el-input clearable size="small" v-model="searchParames.contractType" placeholder="请输入"></el-input>
                </el-form-item> -->
                <!-- <el-form-item label="甲方:">
                    <el-input clearable size="small" v-model="searchParames.partyA" placeholder="请输入"></el-input>
                </el-form-item> -->
                <el-form-item label="销售代表:">
                    <userTree clearable v-model="searchParames.sellerId" :currentValue="searchParames.sellerId"></userTree>
                </el-form-item>
                <el-form-item label="签约时间:">
                    <el-date-picker
                    style="width:100%"
                    size="small"
                    clearable
                    value-format="yyyy-MM-dd"
                    v-model="searchParames.signingDate"
                    type="date"
                    placeholder="选择日期">
                    </el-date-picker>
                </el-form-item>
            </el-form>
        </el-row>
        <span slot="footer" class="dialog-footer">
            <el-button size="small" @click="handleReset">重置</el-button>
            <el-button size="small" type="primary" @click="handleSend">查询</el-button>
        </span>
      </a-modal>
    </div>
</template>

<script>
export default {
    props: ['searchData'],
    data() {
        return {
          searchParames: {
            customerName: '',//客户名称
            contacts: '',//联系人
            contractStatus: '',
            contractType: '',//合同类型
            partyA: '',//甲方
            accountantName: '', //会计
            contractSourceType: '',//合同来源类型
            contractSourceId: '',//合同来源ID
            sellerId:  '',//销售代表
            signingDate: ''
          },
          contractStatusData: [], //联系方式
        };
    },
    methods: {
        handleSend () {
            let searchDate = []
            for(var key in this.searchParames){
                if (this.searchParames[key]) {
                    if (key == 'signingDate') {
                        searchDate.push({
                            key: key,
                            value: this.searchParames[key],
                            type: 'date'
                        })
                    } else if (key == 'contractStatus' || key == 'contractType') {
                        searchDate.push({
                            key: key,
                            value: this.searchParames[key],
                            type: 'enumeration'
                        })
                    } else {
                        searchDate.push({
                            key: key,
                            value: this.searchParames[key],
                            type: 'string'
                        })
                    }
                }
            }
            this.$emit('checkSearch',searchDate)
            this.handleClose()
        },
        checkValue (value) { //来源获取信息
            this.searchParames.contractSourceType = value
        },
        handleClose () {
            this.searchData.show = false
        },
        handleReset () {
            this.searchParames.customerName = ''//客户名称
            this.searchParames.contacts = ''//联系人
            this.searchParames.contractStatus = ''
            this.searchParames.contractType = ''//合同类型
            this.searchParames.partyA = ''//甲方
            this.searchParames.contractSourceType = ''//合同来源类型
            this.searchParames.contractSourceId = ''//合同来源ID
            this.searchParames.sellerId =  ''//销售代表
            this.searchParames.signingDate = ''
            this.searchParames.accountantName = ''
            this.$emit('resetSearch')
            this.$refs.searchParames.resetFields()
        }
    },
    computed: {
      changeDialog () {
        return this.searchData.show
      }
    }, 
    watch: {
      changeDialog: {
        handler (curVal, oldVal) {
          if (curVal) {
            this.$utils.getEnumberation('postContractStatus','contractStatusData',this) //合同状态
            this.searchParames.customerName = this.searchData.customerName
            this.searchParames.contractStatus = this.searchData.contractStatus
          } else {
          }
        }
      }
    },
};
</script>

<style>
#seachDialog .el-dialog{
    padding-bottom: 0; 
    overflow-x: hidden;
}
#seachDialog .el-dialog__footer{
    border-top: #f4f4f4 solid 1px;
}
.ant-modal-body{
    padding: 0
}
</style>
